import React, { Component } from 'react';
import { connect } from 'react-redux';
class Test3 extends Component {
    render() {
        console.log(this.props);
        let { goodsReducer, userReducer, addAgeFn, addpriceFn } = this.props
        return (
            <div>
                <p>我是test3组件</p>
                <p onClick={addpriceFn}>goods:{goodsReducer.goodsname}--{goodsReducer.price}</p>
                <p onClick={addAgeFn}>user:{userReducer.userinfo.username}--{userReducer.userinfo.age}</p>
            </div>
        );
    }
}

// 
function mapStateToProps(state) {
    return state
}

function mapDispatchToProps(dispatch) {
    return {
        addpriceFn() {
            dispatch({ type: 'addprice', payload: 1000 })
        },
        addAgeFn() {
            dispatch({ type: 'addage', payload: 1 })
        }

    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Test3);
